<?php
if( count($errors) ){
  $statusCode   = 0;
  $statusValue  = 'ERROR';
} else if (count($addressLocations) > 0 ) {
  $statusCode   = 1;
  $statusValue  = 'OK';
} else {
  $statusCode   = -1;
  $statusValue  = 'EMPTY';
}
echo '<?xml version="1.0"?>';
?>
<result>
  <status code="<?php echo $statusCode ?>"><?php echo $statusValue ?></status>
<?php if(count($errors)): ?>
  <errors>
  <?php foreach( $errors as $error ): ?>
    <error><?php echo $error; ?></error>
  <?php endforeach; ?>
  </errors>
<?php endif; ?>

<?php if(count($warnings)): ?>
  <warnings>
  <?php foreach( $warnings as $warning ): ?>
    <warning><?php echo $warning; ?></warning>
  <?php endforeach; ?>
  </warnings>
<?php endif; ?>

<?php if(count($addressLocations)) : ?>
  <addresses>
  <?php foreach( $addressLocations as $addressLocation ): ?>
    <address>
      <street><?php echo $addressLocation->getAddress(); ?></street>
      <zipcode><?php echo $addressLocation->getZipCode(); ?></zipcode>
      <city><?php echo $addressLocation->getCity(); ?></city>
      <lat><?php echo $addressLocation->getLat(); ?></lat>
      <lng><?php echo $addressLocation->getLng(); ?></lng>
      <country><?php echo $addressLocation->getCountry(); ?></country>
    </address>
  <?php endforeach; ?>
  </addresses>
<?php endif; ?>
</result>